﻿using UnityEngine;
using UnityEngine.UI;
using System.Collections;

public class PlayerStorage : MonoBehaviour {


	public float fuel;
	public float hull;
	public float carry; 
	
	public float maxfuel;
	public float maxhull;
	public float maxcarry;
	
	public int fuelUpgrades;
	public int hullUpgrades;
	public int carryUpgrades;
	
	public int fuelUpgradesMax;
	public int hullUpgradesMax;
	public int carryUpgradesMax;
	
	public float distance;
	
	public int foodQuantity;
	public int waterQuantity;
	public int hoochQuantity;
	public int partsQuantity;
	
	public float cash;
	
	public int ActiveSettlement;
	
	public int firstrun;
	
	public int trukkOwned;
	public int pickupOwned;
	public int buggyOwned;
	
	public int activeVehicle;
	public int vehiclePaint;
	
	public int Sound;
	
	public void Reset()
	{
		
		PlayerPrefs.DeleteAll();
		PlayerPrefs.SetInt("FirstRun", 0);
		PlayerPrefs.SetFloat("Cash", 30);
		PlayerPrefs.SetFloat("Fuel", 20);
		PlayerPrefs.SetFloat("Hull", 500);
		PlayerPrefs.SetFloat("Carry", 5);
		PlayerPrefs.SetFloat("MaxFuel", 100);
		PlayerPrefs.SetFloat("MaxHull", 500);
		PlayerPrefs.SetFloat("MaxCarry", 10);
		PlayerPrefs.SetInt("FuelUpgrades", 0);
		PlayerPrefs.SetInt("HullUpgrades", 0);
		PlayerPrefs.SetInt("CarryUpgrades", 0);
		PlayerPrefs.SetInt("MaxFuelUpgrades", 5);
		PlayerPrefs.SetInt("MaxHullUpgrades", 5);
		PlayerPrefs.SetInt("MaxCarryUpgrades", 5);
		PlayerPrefs.SetInt("ActiveSettlement", 0);
		PlayerPrefs.SetFloat ("Distance", 100);
		PlayerPrefs.SetInt("foodQuantity", 5);
		PlayerPrefs.SetInt("waterQuantity", 0);
		PlayerPrefs.SetInt("hoochQuantity", 0);
		PlayerPrefs.SetInt("partsQuantity", 0);
		PlayerPrefs.SetInt("TrukkOwned", 0);
		PlayerPrefs.SetInt("PickupOwned", 0);
		PlayerPrefs.SetInt("BuggyOwned", 1);
		PlayerPrefs.SetInt("ActiveVehicle", 2);
		PlayerPrefs.SetInt("VehiclePaint", 0);
		
		PlayerPrefs.SetInt("SoundOn", 0);
		
		Debug.LogWarning("Game Reset");
		
	}
	
	public void LoadValues()
	{
		firstrun = PlayerPrefs.GetInt("FirstRun");
		cash = PlayerPrefs.GetFloat("Cash");
		fuel = PlayerPrefs.GetFloat("Fuel");
		hull = PlayerPrefs.GetFloat("Hull");
		carry = PlayerPrefs.GetFloat("Carry");
		maxfuel = PlayerPrefs.GetFloat("MaxFuel");
		maxhull = PlayerPrefs.GetFloat("MaxHull");
		maxcarry = PlayerPrefs.GetFloat("MaxCarry");
		fuelUpgrades = PlayerPrefs.GetInt("FuelUpgrades");
		hullUpgrades = PlayerPrefs.GetInt("HullUpgrades");
		carryUpgrades = PlayerPrefs.GetInt("CarryUpgrades");
		fuelUpgradesMax = PlayerPrefs.GetInt("MaxFuelUpgrades");
		hullUpgradesMax = PlayerPrefs.GetInt("MaxHullUpgrades");
		carryUpgradesMax = PlayerPrefs.GetInt("MaxCarryUpgrades");
		ActiveSettlement = PlayerPrefs.GetInt("ActiveSettlement");
		distance = PlayerPrefs.GetFloat("Distance");
		foodQuantity = PlayerPrefs.GetInt("foodQuantity");
		waterQuantity = PlayerPrefs.GetInt("waterQuantity");
		hoochQuantity = PlayerPrefs.GetInt("hoochQuantity");
		partsQuantity = PlayerPrefs.GetInt("partsQuantity");
		
		trukkOwned = PlayerPrefs.GetInt("TrukkOwned");
		pickupOwned = PlayerPrefs.GetInt("PickupOwned");
		buggyOwned = PlayerPrefs.GetInt("BuggyOwned");
		activeVehicle = PlayerPrefs.GetInt("ActiveVehicle");
		vehiclePaint = PlayerPrefs.GetInt("VehiclePaint");
		
		Sound = PlayerPrefs.GetInt("SoundOn");
		
		Debug.LogWarning("Game Loaded");
	}
	
	public void SetValues()
	{
		PlayerPrefs.SetInt("FirstRun", 1);
		PlayerPrefs.SetFloat("Cash", cash);
		PlayerPrefs.SetFloat("Fuel", fuel);
		PlayerPrefs.SetFloat("Hull", hull);
		PlayerPrefs.SetFloat("Carry", carry);
		PlayerPrefs.SetFloat("MaxFuel", maxfuel);
		PlayerPrefs.SetFloat("MaxHull", maxhull);
		PlayerPrefs.SetFloat("MaxCarry", maxcarry);
		PlayerPrefs.SetInt("FuelUpgrades", fuelUpgrades);
		PlayerPrefs.SetInt("HullUpgrades", hullUpgrades);
		PlayerPrefs.SetInt("CarryUpgrades", carryUpgrades);
		PlayerPrefs.SetInt("MaxFuelUpgrades", fuelUpgradesMax);
		PlayerPrefs.SetInt("MaxHullUpgrades", hullUpgradesMax);
		PlayerPrefs.SetInt("MaxCarryUpgrades", carryUpgradesMax);
		PlayerPrefs.SetInt("ActiveSettlement", ActiveSettlement);
		PlayerPrefs.SetFloat("Distance", distance);
		PlayerPrefs.SetInt("foodQuantity", foodQuantity);
		PlayerPrefs.SetInt("waterQuantity", waterQuantity);
		PlayerPrefs.SetInt("hoochQuantity", hoochQuantity);
		PlayerPrefs.SetInt("partsQuantity", partsQuantity);
		
		PlayerPrefs.SetInt("TrukkOwned", trukkOwned);
		PlayerPrefs.SetInt("PickupOwned", pickupOwned);
		PlayerPrefs.SetInt("BuggyOwned", buggyOwned);
		PlayerPrefs.SetInt("ActiveVehicle", activeVehicle);
		PlayerPrefs.SetInt("VehiclePaint", vehiclePaint);
		
		PlayerPrefs.SetInt("SoundOn", Sound);
		
		Debug.LogWarning("Game Saved");
	}
	
	
	
}
